package document.dao;

import java.util.HashMap;
import java.util.List;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import document.vo.AprovalInfo;
import document.vo.DocumentRefDept;
import document.vo.DocumentVO;

public class DocumentDAO {
	private SqlMapClientTemplate client;
	
	public void setSqlMapClientTemplate(SqlMapClientTemplate client){
		this.client = client;
	}
	
	public void registerDoc(DocumentVO dvo){
		client.insert("registerDoc", dvo);
	}
	public void registerAprovalInfo(AprovalInfo aInfo){
		client.insert("registerAprovalInfo",aInfo);
	}
	public void registerDocRefDept(DocumentRefDept drd){
		client.insert("registerDocRefDept", drd);
	}
	public List selectAllDoc(){
		List list = client.queryForList("selectAllDocument");
		return list;
	}
	public List selectAllAprovalInfo(){
		List list = client.queryForList("selectAllAprovalInfo");
		return list;
	}
	public List selectAllDocRefDept(){
		List list = client.queryForList("selectAllDocRefDept");
		return list;
	}
	public DocumentVO selectDoc(String documentId){
		DocumentVO dvo = (DocumentVO)client.queryForObject("selectDocument", documentId);
		return dvo;
	}
	public List selectAprovalInfo(String documentId){
		List list = client.queryForList("selectAprovalInfo", documentId);
		return list;
	}
	public List selectDocRefDept(String documentId){
		List list = client.queryForList("selectDocRefDept", documentId);
		return list;
	}
	
	public int deleteDoc(String documentId){
		int cnt = client.delete("deleteDoc", documentId);
		return cnt;
	}
	public int deleteAprovalInfo(String documentId){
		int cnt = client.delete("deleteAprovalInfo", documentId);
		return cnt;
	}
	public int deleteDocRefDept(String documentId){
		int cnt = client.delete("deleteDocRefDept", documentId);
		return cnt;
	}
	public int updateDoc(DocumentVO dvo){
		int cnt = client.update("updateDoc", dvo);
		return cnt;
	}
	public int updateAprovalInfo(AprovalInfo aInfo){
		int cnt = client.update("updateAprovalInfo", aInfo);
		return cnt;
	}
	public int updateDocRefDept(DocumentRefDept drd){
		int cnt = client.update("updateDocRefDept", drd);
		return cnt;
	}
	public List selectDocByWriter(String writer){
		List list = client.queryForList("selectDocByWriter", writer);
		return list;
	}
	
	public List selectDeptByDeptId(String deptId){
		List list = client.queryForList("selectDeptByDeptId", deptId);
		return list;
	}
	
	public List selectAprovalInfoByState(String state){
		List list = client.queryForList("selectAprovalInfoByState", state);
		return list;
	}
	
	public void setAprovalState(HashMap map){
		client.update("setAprovalState", map);
	}
	public void setAprovalRefuse(String documentId){
		client.update("setAprovalRefuse", documentId);
	}
	
}
